package com.ghp.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author ghp
 */
public class SqlSessionFactoryUtil {
    private static SqlSessionFactory sqlSF;

    static{
        String resource = "./mybatis-config.xml";
        try {
            InputStream is = Resources.getResourceAsStream(resource);
            sqlSF = new SqlSessionFactoryBuilder().build(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static SqlSessionFactory getSqlSF() {
        return sqlSF;
    }
}
